.TH std::is_void 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::is_void \- std::is_void

.SH Synopsis
   Defined in header <type_traits>
   template< class T >              \fI(since C++11)\fP
   struct is_void;

   std::is_void is a UnaryTypeTrait.

   Checks whether T is a void type. Provides the member constant value that is equal to
   true, if T is the type void, const void, volatile void, or const volatile void.
   Otherwise, value is equal to false.

   If the program adds specializations for std::is_void or std::is_void_v, the behavior
   is undefined.

.SH Template parameters

   T - a type to check

   Helper variable template

   template< class T >                                   \fI(since C++17)\fP
   inline constexpr bool is_void_v = is_void<T>::value;



Inherited from std::integral_constant

.SH Member constants

   value    true if T is the type void (possibly cv-qualified), false otherwise
   \fB[static]\fP \fI(public static member constant)\fP

.SH Member functions

   operator bool converts the object to bool, returns value
                 \fI(public member function)\fP
   operator()    returns value
   \fI(C++14)\fP       \fI(public member function)\fP

.SH Member types

   Type       Definition
   value_type bool
   type       std::integral_constant<bool, value>

.SH Possible implementation

   template<class T>
   struct is_void : std::is_same<void, typename std::remove_cv<T>::type> {};

.SH Example


// Run this code

 #include <type_traits>

 void foo();

 static_assert
 (
     std::is_void_v<void> == true and
     std::is_void_v<const void> == true and
     std::is_void_v<volatile void> == true and
     std::is_void_v<void*> == false and
     std::is_void_v<int> == false and
     std::is_void_v<decltype(foo)> == false and
     std::is_void_v<std::is_void<void>> == false
 );

 int main() {}

.SH See also

   is_array    checks if a type is an array type
   \fI(C++11)\fP     \fI(class template)\fP
   is_pointer  checks if a type is a pointer type
   \fI(C++11)\fP     \fI(class template)\fP
   is_enum     checks if a type is an enumeration type
   \fI(C++11)\fP     \fI(class template)\fP
   is_union    checks if a type is a union type
   \fI(C++11)\fP     \fI(class template)\fP
   is_class    checks if a type is a non-union class type
   \fI(C++11)\fP     \fI(class template)\fP
   is_function checks if a type is a function type
   \fI(C++11)\fP     \fI(class template)\fP
   is_object   checks if a type is an object type
   \fI(C++11)\fP     \fI(class template)\fP
